<?php
// +----------------------------------------------------------------------
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: rainfer <81818832@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\model;

use think\Model;

/**
 * 文章模型
 * @package app\admin\model
 */
class Message extends Model
{
	protected $table = 'message';

    /*
     * 添加站内信用户记录
     * @param int $messageContentId  消息主体编号
     * @param mixed $acceptUids 接收用户编号
     * @param int $statue 阅读状态
     * @return 插入成功或者失败
     */
    public function addMessageInfo($messageContentId, $acceptUids, $statue = 0)
    {
        $messageContentId = intval($messageContentId);
        $statue = intval($statue);
        $dataList = array();
        if ($messageContentId > 0 && !empty($acceptUids) ) {
            $i = 0;
            foreach ($acceptUids as $key => $value ) {
                $dataList[$i]['mc_id'] = $messageContentId;
                $dataList[$i]['rec_uid'] = intval($value);
                $dataList[$i]['statue'] = $statue;
                $i ++;
            }
            $result = db($this->table)->insertAll($dataList);
        }

        return (isset($result) && $result > 0) ? 1 : 0;
    }
}
